package stravel

class Hotel {
	
	String name
	String remark
	String address1
	String address2
	String postcode
	String generalLine
	String website
	static belongsTo = [city:City,state:State, starRating:StarRating]
	BigDecimal rate
	Integer noOfVote
	
	
	static hasMany = [comments:HotelComment, entries:BlogEntry]

    static constraints = {
		name(nullable:false, blank:false)
		remark(nullable:true, blank:true)
		city(nullable:false)
		state(nullable:true)
		starRating(nullable:true)
		address1(nullable:true, blank:true)
		address2(nullable:true, blank:true)
		postcode(nullable:true, blank:true)
		generalLine(nullable:true, blank:true)
		website(nullable:true, blank:true)
		rate(nullable:true, blank:true)
		noOfVote(nullable:true, blank:true)
		
    }
	
	String toString(){
		return name
	}
	
	Integer noOfView(){
		Integer c = 0
		c = HotelViewCounter.createCriteria().count{
			eq("hotel.id",id)
		}
		return c
	}
}
